/** @format */

/**
 *@desc: 业务类 -- 气模块处理
 *@author: ptt
 *@date: 2023/12/18
 */
const handleVal = (level, type) => {
    let color = '';
    let text = '';
    let textLevel = '';
    switch (level) {
        case '1':
        case 1:
        case '优':
            color = '#24bd5d';
            text = '优';
            textLevel = '一级';
            break;
        case '2':
        case 2:
        case '良':
            color = '#d8bc37';
            text = '良';
            textLevel = '二级';
            break;
        case '3':
        case 3:
        case '轻度':
            color = '#f87c12';
            text = '轻度';
            textLevel = '三级';
            break;
        case '4':
        case 4:
        case '中度':
            color = '#f60000';
            text = '中度';
            textLevel = '四级';
            break;
        case '5':
        case 5:
        case '重度':
            color = '#94004b';
            text = '重度';
            textLevel = '五级';
            break;
        case '6':
        case 6:
        case '严重':
            color = '#6f001f';
            text = '严重';
            textLevel = '六级';
            break;

        default:
            color = '#b0b0b0';
            text = '-';
            textLevel = '-';
            break;
    }
    if (type == 'color') {
        return color;
    } else if (type == 'text') {
        return text;
    } else if (type == 'textLevel') {
        return textLevel;
    }
};

const airObj = {
    // 不同空气对应的颜色
    setColor: level => {
        return handleVal(level, 'color');
    },
    // 不同空气对应的等级文字
    setText: level => {
        return handleVal(level, 'text');
    },
    // 数字转化为文字
    setTextLevel: level => {
        return handleVal(level, 'textLevel');
    }
};

export default airObj;
